<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>华胜后台管理</title>
		<link rel="stylesheet" type="text/css" href="css/unified.css">
		<script src="plugins/layui/layui.js"></script>

		<style type="text/css">

		</style>
	</head>

	<body>

		<fieldset class="layui-elem-field layui-field-title">
			<legend>微信用户</legend>
			<div class="layui-field-box">
				<table class="layui-table smtable"  id="VipinTable">
					<thead>
						<tr>
							<td style="width: 28px;">操作</td>
							<td style="width: 100px;">状态</td>
							<td >userId</td>
							<td >wechatId</td>
							<td >openId</td>
							<!--<td>openId</td>-->
							<!--<td>wechatId</td>-->
							<!--<td>userId</td>-->
							<td style="width: 130px;">姓名 <span class="layui-badge-dot"></span></td>
							<td>介绍  <span class="layui-badge-dot"></span></td>
							<td style="width: 100px;">地区编号 <span class="layui-badge-dot"></span></td>
							<td style="width: 100px;">地区 <span class="layui-badge-dot"></span></td>
							
							<td style="width: 100px;">头像</td>
							
						</tr>
					</thead>
					<tbody>
						<!--<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>-->
					</tbody>
					<tfoot>
						<tr>
							<td colspan='100%' id="addtr">点击添加+</td>
						</tr>
					</tfoot>
				</table>
			</div>
		</fieldset>

		
		<div class="layui-layer-btn layui-layer-btn-" style="margin-bottom: 35px;">
			<div class="layui-btn yesInsert">确认添加到客服名单</div>
			
		</div>
		
		
		<!--图片的iframe-->
		<iframe id="framFile" name="framFile" style="display: none;"></iframe>
		
	</body>

	<script src="js/jquery-3.2.1.min.js"></script>
	<script src="js/allajax.js"></script>
	<script>
		//	$(".stockinTable")
		layui.use(['layer', 'form', 'element', 'table', 'laydate', 'laypage'], function() {
			var layer = layui.layer,
				form = layui.form,
				element = layui.element,
				table = layui.table,
				laydate = layui.laydate,
				laypage = layui.laypage;

			
			
				
			$("#addtr").click(function() {
				console.log("111")
				var index = layer.open({
					type: 2,
					title: "微信用户选择",
					area: ['100%', '100%'],
					maxmin: true,
					shade: 0,
					content: 'vip.html?urltype=choice'
				});

			})
			$(".yesInsert").click(function(){
				if($("#VipinTable tbody tr").length != 0 ){
					$.each($("#VipinTable tbody tr"), function(idx,obj) {
						var Trstats =  $("#VipinTable tbody tr:eq("+idx+") td:eq(1)").attr("data-stats");
						if(Trstats == 0){
							var thisdata = {} ;
							var thisobj = $("#VipinTable tbody tr:eq("+idx+") ");
							thisdata.userId =thisobj.children(".userId").html();
							thisdata.openId =  thisobj.children(".openId").html();
							thisdata.wechatId =  thisobj.children(".wechatId").html();
							thisdata.salesmanName =  thisobj.find(".nickName").val();
							thisdata.introduce =  thisobj.find(".introduce").val();
							
							thisdata.addTime = new Date().getTime();
							thisdata.headPhoto = thisobj.find("img").attr("src");
							thisdata.region =thisobj.find(".province").val();
							thisdata.adcode = thisobj.find(".adcode").val();
	
	//						console.log(thisdata)
							var thisidx  = idx;
							AjaxPostFn('system/salesman/insertinfo',JSON.stringify(thisdata),function(data){
								var thistd = $("#VipinTable tbody tr:eq("+thisidx+") td:eq(1)")
								if(data.htmlState.status == 200){
									thistd.html("添加成功");
									thistd.css("color","#0db832");
									thistd.attr("data-stats","1");
								}else{
									thistd.html("添加失败");
									thistd.css("color","#ff2d2d");
									thistd.attr("data-stats","2");
								}
							},thisidx)
						}
					})
									
				}else{
					layer.msg("请选择至少一件商品");
				}
				
			
			})
		})
		
		
		function deltr (objidx){
		
			layer.confirm('是否要删除当前选中行信息', function(index){
			  //do something
			  $("#VipinTable tbody tr:eq("+objidx+")").remove();
			  layer.close(index);
			});    
			
		}
	</script>

</html>